home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / mschrt / demov2.c next >
Text File  |  1989-02-02  |  3KB  |  78 lines

  1. /*---------------------------------------------------------------------------
  2.  |  This program demonstrates some of the functions in MSCHRT V2.00         |
  3.  |                                                                          |
  4.  |  (c) 1988 Ryle Design, P.O. Box 22, Mt. Pleasant, Michigan 48804         |
  5.  ---------------------------------------------------------------------------*/
  6.  
  7.  
  8. #include <stdio.h>
  9. #include <conio.h>
  10. #include <math.h>
  11.  
  12. #include "mschrt.h"
  13.  
  14.  
  15. void sin_funct(void)
  16. /*---------------------------------------------------------------------------
  17.  |  A simple function to time.  MSCHRT will tell us how many times this     |
  18.  |  function was called and how much time we spent here.                    |
  19.  |                                                                          |
  20.  |  Globals referenced: none                                                |
  21.  |                                                                          |
  22.  |  Arguments: void                                                         |
  23.  |                                                                          |
  24.  |  Returns: void                                                           |
  25.  ---------------------------------------------------------------------------*/
  26. {
  27.     double  alpha;
  28.  
  29.     t_entry(2);                                             /* start timer 2 */
  30.  
  31.     alpha = sin(2.2734593);                                 /* do something */
  32.  
  33.     t_exit(2);                                              /* stop timer 2 */
  34.  
  35. } /* sin_funct */
  36.  
  37.  
  38.  
  39. void main(void)
  40. {
  41.     long unsigned   hits, elapsed;
  42.     int             indx;
  43.  
  44.     t_start();                                              /* init MSCHRT first thing */
  45.     t_entry(0);                                             /* we use timer 0 to time whole run */
  46.  
  47.     printf("MSCHRT V2.00 Demonstration\n\n");
  48.  
  49.     printf("Press any key >> ");
  50.  
  51.     t_entry(1);                                             /* time getch() with timer 1 */
  52.     getch();
  53.     t_exit(1);
  54.  
  55.     t_ask_timer(1,&hits,&elapsed);                          /* get timer 1 results */
  56.  
  57.     printf("\nResponse time was %lu microseconds, or %f seconds\n",elapsed,elapsed/1000000.0);
  58.  
  59.     printf("\nCalling sin function with embedded timer 100 times ... ");
  60.     for (indx=0; indx<100; indx++) sin_funct();
  61.     printf("complete\n\n");
  62.  
  63.     t_exit(0);                                              /* stop timer timing total run time */
  64.     t_stop();                                               /* shut down MSCHRT primitives */
  65.  
  66.     t_rname("MSCHRT Demonstration");                        /* report title */
  67.     t_name(0,"Total run time");                             /* give each timer a name */
  68.     t_name(1,"getch() response");
  69.     t_name(2,"sin() function");
  70.  
  71.     t_report(0);                                            /* do report - (0) goes to CRT */
  72.  
  73.     printf("\nDemo complete\n");                            /* all done ... */
  74.  
  75. } /* main */
  76.  
  77.  
  78.